class Logger {
  static info(module, message) {
    const timestamp = new Date().toISOString();
    console.log(`[${timestamp}] [INFO] [${module}] ${message}`);
  }

  static warn(module, message) {
    const timestamp = new Date().toISOString();
    console.warn(`[${timestamp}] [WARN] [${module}] ${message}`);
  }

  static error(module, message, error = null) {
    const timestamp = new Date().toISOString();
    let logMessage = `[${timestamp}] [ERROR] [${module}] ${message}`;
    
    if (error) {
      logMessage += `\n错误详情: ${error.message}`;
      if (error.stack) {
        logMessage += `\n堆栈跟踪: ${error.stack}`;
      }
    }
    
    console.error(logMessage);
  }

  static debug(module, message) {
    if (process.env.NODE_ENV === 'development') {
      const timestamp = new Date().toISOString();
      console.log(`[${timestamp}] [DEBUG] [${module}] ${message}`);
    }
  }
}

module.exports = Logger;